package fr.SDroid.Graph;

import java.io.Serializable;
import java.util.Vector;

import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;


public class Ligne implements Serializable{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private String _name = new String();
	private Vector<Station> _listStation = new Vector<Station>();
	private Station _terminus1 = null;
	private Station _terminus2 = null;
	private Drawable _image = null;
	
	Station sta1 = null;
	Station sta2 = null;

	public Ligne(String name) {
			_name=name;
	}
	
	public void setTerminus(Station terminus1, Station terminus2) {
		_terminus1=terminus1;
		_terminus2=terminus2;
	}
	
	public void setImage(Drawable image) {
		_image = image;
	}
	
	public Drawable getImage() {
		return _image;
	}
	
	public String getName() {
		return _name;
	}
	
	public void addStation(Station station) {
		_listStation.add(station);
	}
	
	public Vector<Station> getListStation() {
		return _listStation;
	}
	
	public void createLien(Station station1, Station station2) {
		station1.addLien(station2);
		station2.addLien(station1);
	}
	
	public void createUniqueLien(Station station1, Station station2) {
		station1.addLien(station2);
	}
	
	public void createUniqueLien(Integer station1, Integer station2) {
		sta1 = null;
		sta2 = null;
		for(int i = 0; i < _listStation.size(); i++) {
			Station temp = _listStation.get(i);
			if(temp.getId().equals(station1))
				sta1 = temp;
			if(temp.getId().equals(station2))
				sta2 = temp;
		}
		
		if(sta1 != null && sta2 != null)
			createUniqueLien(sta1, sta2);
		else
			System.out.println("impossible de creer le lien");
		
	}

	
	
	
	public void createLien(Integer station1, Integer station2) {
		sta1 = null;
		sta2 = null;
		for(int i = 0; i < _listStation.size(); i++) {
			Station temp = _listStation.get(i);
			if(temp.getId().equals(station1))
				sta1 = temp;
			if(temp.getId().equals(station2))
				sta2 = temp;
		}
		
		if(sta1 != null && sta2 != null)
			createLien(sta1, sta2);
		else
			System.out.println("impossible de creer le lien");
	}
}
